//workbook.js
import React, { Component } from 'react';
import Worksheet from './worksheet';
export default class Workbook extends Component {
    componentDidMount(){
        this.props.onRef(this)  //这个就是把自身传给调用者
    }

    workSheetRef=(ref)=>{
        this.workSheet = ref
    }

    //save table
    saveTable=(report_id)=>{
        this.workSheet.saveTable(report_id);
    }
//追加行
    appendRow=()=>{
        this.workSheet.appendRow();
    }

    //insertRow
    insertRow=()=>{
        this.workSheet.insertRow();
    }

    //deleteRow
    deleteRow=()=>{
        this.workSheet.deleteRow();
    }

    //追加列
    appendCol=()=>{
        this.workSheet.appendCol();
    }

    //insertRow
    insertCol=()=>{
        this.workSheet.insertCol();
    }

    //deleteRow
    deleteCol=()=>{
        this.workSheet.deleteCol();
    };
    //align
    align=(d)=>{
       this.workSheet.align(d);
    }
    // hiden data
    hidenData=(v)=>{
        this.workSheet.hidenData(v);
    }

    isThousandsFormat=()=>{
        this.workSheet.isThousandsFormat();
    };

    isPercentageFormat=()=>{
        this.workSheet.isPercentageFormat();
    };

    clearNumFormat=()=>{
        this.workSheet.clearNumFormat();
    };

    setDecimalPlaces=(p)=>{
        this.workSheet.setDecimalPlaces(p);
    };


    editFont=(t)=>{
        this.workSheet.editFont(t);
    };

    modifyBorderStyle=(t)=>{
        this.workSheet.modifyBorderStyle(t);
    }
    mergeCells=()=>{
        this.workSheet.mergeCells();
    }

    splitCells=()=>{
        this.workSheet.splitCells();
    }


    saveFormulaToCell=(fomulaTxt)=>{
        this.workSheet.saveFormulaToCell(fomulaTxt);
    }

//是否选中了单元格
    hasSelectedCell=()=>{
        return this.workSheet.hasSelectedCell();
    }

    getSelectCellValue=()=>{
        return this.workSheet.getSelectCellValue();
    }




    render() {
        let _reportId=this.props.reportId;
        return (
            <div className="workbook">
                <div className="worksheet">
                    <Worksheet onRef={this.workSheetRef} reportId={_reportId}/>
                </div>
            </div>
        )
    }
}
